function y = gmmsvm_classify(X, gmm, hp, num_candidates)

num_classes = size(gmm.model, 1);
num_points = size(X, 1);

logp = zeros(num_points, num_classes);

for j = 1 : num_classes
    fprintf('Calculating probabilities for class %d\n', gmm.label(j));
    logp(:,j) = gmm_logpdf(X, gmm.model{j}) + log(gmm.prior(j));
end

[~, best_classes] = sort(logp, 2, 'descend');
best_classes = best_classes(:,1:num_candidates);

y = gsclassify(X, hp, best_classes);